/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package opconectarse;

/**
 *
 * @author house
 */

import java.sql.*;

public class OpConectarse {

   static String bd = "OpConectarse";
   static String login = "root";


   static String password = "pelikan";
   static String url = "jdbc:mysql://localhost/"+bd;

   public static void main(String[] args) throws Exception {

      Connection conn = null;

      try {

         Class.forName("com.mysql.jdbc.Driver").newInstance();

         conn = DriverManager.getConnection(url,login,password);

         if (conn != null) {
            System.out.println("Conexión a base de datos "+url+" ... Ok");
            conn.close();
         }
      }
      catch(SQLException ex) {
         System.out.println("Hubo un problema al intentar conectarse con la base de datos "+url);
      }
      catch(ClassNotFoundException ex) {
         System.out.println(ex);
      }

   }
}
    }
}
